package com.hongkzh.www.shop.controller;

import com.auth0.jwt.interfaces.Claim;
import com.hongkzh.www.conmon.BusinessException;
import com.hongkzh.www.conmon.JwtUtil;
import com.hongkzh.www.conmon.ReqResponse;
import com.hongkzh.www.shop.service.*;
import com.hongkzh.www.swagger.annotation.*;
import com.hongkzh.www.user.service.UserService;
import com.jfinal.aop.Clear;
import com.jfinal.core.Controller;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author martins
 */
@Api(tag = "shop", description = "乐购")
public class ShopController extends Controller {
    CategoryService categoryService = new CategoryService();
    ProductService productService = new ProductService();
    ShopService shopService = new ShopService();
    AccountService accountService = new AccountService();
    @ApiOperation(url = "/v1/shop/getCategoryList", tag = "shop", httpMethod = "post", description = "乐购-一级分类")

    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{    categoryId  分类id    name 名称   }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })

    public void getCategoryList() {
        ReqResponse<List<Record>> r = new ReqResponse();
        List<Record> record = categoryService.getCategoryList();
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/getSubCategoryList", tag = "shop", httpMethod = "post", description = "乐购-子分类")
    @Params({
            @Param(name = "categoryId", description = "分类id ", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ imgSrc 上部广告图   categorys[ categoryId  分类id  imgSrc 图片 name 名称 ] }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getSubCategoryList() {
        String pid = getPara("categoryId");
        ReqResponse<Record> r = new ReqResponse();
        List<Record> records = categoryService.getSubCategoryList(pid);
        Record p = categoryService.getCategoryById(pid);
        Record record = new Record();
        record.set("imgSrc", p.get("imgSrc"));
        record.set("categorys", records);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/getCategoryProductList", tag = "shop", httpMethod = "post", description = "乐购-子分类商品列表")
    @Params({
            @Param(name = "categoryId", description = "分类id ", required = false, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string"),
            @Param(name = "sortId", description = "排序字段 综合create_date  价格 integral ", required = false, dataType = "string"),
            @Param(name = "sortValue", description = "排序值 asc 升 desc 降 ", required = false, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{    productId 商品id imgSrc 图片 title 标题 subtitle 副标题 integral 价格 couponCount 可用券数量 }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getCategoryProductList() {
        String pid = getPara("categoryId");
        int pageNumber = getParaToInt("pageNumber");
        String sortId = getPara("sortId");
        String sortValue = getPara("sortValue");
        if (StrKit.isBlank(sortId)) {
            sortId = "create_date";
        }
        if (StrKit.isBlank(sortValue)) {
            sortValue = "desc";
        }
        ReqResponse<Page<Record>> r = new ReqResponse();
        Page<Record> records = productService.getCategoryProductList(pid, pageNumber, sortId, sortValue);

        r.setData(records);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/getMainList", tag = "shop", httpMethod = "post", description = "乐购-主页接口")

    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ carousels 轮播图[imgSrc图片路径 imgRank 序号   model 1商品2专题  productId 产品id specialId 专题id] " +
                            "luckyVoucher 爆款活动[beginDate 开始时间 endDate 结束时间 sortDate 离结束多久  currentTime 当前时间 productId 产品id imgSrc图片 integral价格  title 标题 ，discount折扣 discountIntegral 折扣后价格]  " +
                            "hotsShops 热门店铺{categoryId分类id  categoryName 分类名称 imgSrc分类图片[imgSrc图片 title标题 shopId 店铺id ] }  " +
                            "selectedProducts 精选商品[productId 产品id imgSrc图片 integral价格   title 标题 ， ]  " +
                            "categorys 分类{categoryId分类id  categoryName 分类名称 imgSrc分类图片 }  " +
                            "}"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getMainList() {

        ReqResponse<Record> r = new ReqResponse();
        List<Record> carousels = categoryService.getCarouselList(1);
        List<Record> categorys = productService.getCategorysList();
        List<Record> selectedProducts = productService.getSelectedProducts();
        List<Record> hotsShops = productService.getHotsShops();
        List<Record> luckyVoucher = productService.getluckyVoucher();
        Record record = new Record();
        record.set("luckyVoucher", luckyVoucher);
        record.set("carousels", carousels);
        record.set("hotsShops", hotsShops);
        record.set("selectedProducts", selectedProducts);
        record.set("categorys", categorys);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/getNewMainList", tag = "shop", httpMethod = "post", description = "乐购-新品主页接口")

    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ carousels 轮播图[imgSrc图片路径 imgRank 序号   model 1商品2专题  productId 产品id specialId 专题id] " +
                            "recommends 推荐[productId 产品id imgSrc图片 integral价格  title 标题 ，subtitle 副标题   ]  " +
                            "}"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getNewMainList() {

        ReqResponse<Record> r = new ReqResponse();
        List<Record> carousels = categoryService.getCarouselList(2);
        List<Record> recommends = productService.getNewRecommendsList();


        Record record = new Record();
        record.set("recommends", recommends);
        record.set("carousels", carousels);

        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/getNewProductList", tag = "shop", httpMethod = "post", description = "乐购-新品主页-新品商品列表")
    @Params({

            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string"),
            @Param(name = "sortId", description = "排序字段 综合create_date  价格 integral ", required = false, dataType = "string"),
            @Param(name = "sortValue", description = "排序值 asc 升 desc 降 ", required = false, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{      productId 商品id imgSrc 图片 title 标题 subtitle 副标题 integral 价格  }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getNewProductList() {
        int pageNumber = getParaToInt("pageNumber");
        String sortId = getPara("sortId");
        String sortValue = getPara("sortValue");
        if (StrKit.isBlank(sortId)) {
            sortId = "create_date";
        }
        if (StrKit.isBlank(sortValue)) {
            sortValue = "desc";
        }
        ReqResponse<Page<Record>> r = new ReqResponse();
        Page<Record> records = productService.getNewProductList(pageNumber, sortId, sortValue);

        r.setData(records);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/getDiscountsList", tag = "shop", httpMethod = "post", description = "乐购-折扣列表")
    @Params({

            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ beginDate 开始时间 endDate 结束时间 sortDate 离结束多久  currentTime 当前时间  records {      list[ productId 产品id imgSrc图片 integral价格   title 标题 ，activityStocks 活动库存 activityPrice活动价格 discount折扣 people 参与人数 ] }}"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getDiscountsList() {
        int pageNumber = getParaToInt("pageNumber");

        ReqResponse<Map> r = new ReqResponse();
        Page<Record> records = productService.getdDiscountsList(pageNumber);
        Map map = new HashMap();
        map.put("records", records);
        int currentHour = 0, beginDate = 0, endDate = 0;
        String currentTime = "";
        if (null != records && null != records.getList() && records.getList().size() > 0) {
            currentHour = records.getList().get(0).getInt("currentHour");
            beginDate = records.getList().get(0).getInt("beginDate");
            endDate = records.getList().get(0).getInt("endDate");
            currentTime = records.getList().get(0).getStr("currentTime");
        }
        map.put("currentTime", currentTime);
        map.put("beginDate", beginDate);
        map.put("endDate", endDate);
        map.put("currentHour", currentHour);
        map.put("sortDate", currentHour - beginDate);
        if (currentHour >= beginDate && currentHour < endDate) {
            map.put("sortDate", 0);
        } else {
            if (currentHour - beginDate > 0) {
                map.put("sortDate", currentHour - beginDate - 24);
            }
        }
        r.setData(map);
        renderJson(r);
    }


    @ApiOperation(url = "/v1/shop/getProductDiscountsById", tag = "shop", httpMethod = "post", description = "乐购-折扣商品详情")
    @Params({

            @Param(name = "productId", description = "产品id", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{  beginDate 开始时间 endDate 结束时间 sortDate 离结束多久  currentTime 当前时间" +
                            "activityStocks 活动库存 activityPrice活动价格 discount折扣 people 参与人数" +
                            " productId 产品id  title 标题 subtitle 副标题 integral 价格 afterService 服务 descript 详情  " +
                            "  images [imgSrc] 主轮播图 " +
                            "colors [productColorId 产品颜色id name 颜色名称] specs [productSpecId 产品规格id name 规格名称] " +
                            "skus [productSpecId 产品规格id productColorId 产品颜色id  sukId sku的id stocks 库存 integral 价格 ] " +
                            "recs 推荐[productId 产品id  title 标题  integral 价格   imgSrc 主 图]" +
                            "discounts 折扣列表[productId 产品id  beginPeoples 开始人数 endPeoples 结束人数 discount 折扣  isCurrent 1是当前0不是]" +

                            "comment评论 {{  userId 评论用户 uName 评论用户名称 headImg 评论用户头像 content 内容 replyUserId 回复id rName回复用户名称 rheadImg回复用户头像 createDate 创建时间  images[imgSrc 评论图片] } } }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getProductDiscountsById() {
        String productId = getPara("productId");

        ReqResponse<Record> r = new ReqResponse();
        Record record = productService.getProductDiscountsById(productId);

        int currentHour = 0, beginDate = 0, endDate = 0;
        String currentTime = "";
        if (null != record) {
            currentHour = record.getInt("currentHour");
            beginDate = record.getInt("beginDate");
            endDate = record.getInt("endDate");
            currentTime = record.getStr("currentTime");
        }
        record.set("currentTime", currentTime);
        record.set("beginDate", beginDate);
        record.set("endDate", endDate);
        record.set("currentHour", currentHour);
        record.set("sortDate", currentHour - beginDate);
        if (currentHour >= beginDate && currentHour < endDate) {
            record.set("sortDate", 0);
        } else {
            if (currentHour - beginDate > 0) {
                record.set("sortDate", currentHour - beginDate - 24);
            }
        }
        r.setData(record);
        renderJson(r);
    }/*
    @ApiOperation(url = "/v1/shop/getLuckyBurstALLList", tag = "shop", httpMethod = "post",description = "乐购-爆款列表")
    @Params({

            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="成功",responseHeaders={
                    @ResponseHeader(name="code",description = " 0成功 1失败"),
                    @ResponseHeader(name="data",description = "{ beginDate 开始时间 endDate 结束时间 sortDate 离结束多久  currentTime 当前时间  records {      list[ productId 产品id imgSrc图片 integral价格  subtitle 副标题 title 标题 ，activityStocks 活动库存 activityPrice活动价格 lastStocks 剩余库存 [users {  uid 用户id,headImg头像 ,uName 用户名称} ] ] }}"),
                    @ResponseHeader(name="msg",description = "失败原因") })

    })
    public void getLuckyBurstALLList(){
        int pageNumber=getParaToInt("pageNumber");

        ReqResponse<Map> r=new ReqResponse();
        Page<Record>  records= productService.getLuckyBurstALLList(pageNumber);
        Map map=new HashMap();
        map.put("records",records);
        int currentHour=0,beginDate=0,endDate=0 ;
        String currentTime="";
        if(null!=records&&null!=records.getList()&&records.getList().size()>0) {
            currentHour = records.getList().get(0).getInt("currentHour");
            beginDate =  records.getList().get(0).getInt("beginDate");
            endDate =  records.getList().get(0).getInt("endDate");
            currentTime= records.getList().get(0).getStr("currentTime");
        }
        map.put("currentTime", currentTime);
        map.put("beginDate", beginDate);
        map.put("endDate", endDate);
        map.put("currentHour", currentHour);
        map.put("sortDate", currentHour-beginDate);
        if(currentHour>=beginDate&&currentHour<endDate){
            map.put("sortDate",0);
        }
        else{
            if(currentHour-beginDate>0) {
                map.put("sortDate", currentHour-beginDate-24);
            }
        }
        r.setData(map);
        renderJson(r);
    }*/

    /* @ApiOperation(url = "/v1/shop/getLuckyBurstById", tag = "shop", httpMethod = "post",description = "乐购-爆款商品详情")
     @Params({

             @Param(name = "productId", description = "产品id", required = true, dataType = "string")
     })
     @ApiResponses({
             @ApiResponse(code=200,message="成功",responseHeaders={
                     @ResponseHeader(name="code",description = " 0成功 1失败"),
                     @ResponseHeader(name="data",description = "{  beginDate 开始时间 endDate 结束时间 sortDate 离结束多久  currentTime 当前时间" +
                             "activityStocks 活动库存 activityPrice活动价格   lastStocks 剩余库存 [users {  uid 用户id,headImg头像 ,uName 用户名称} ] ] }" +
                             " productId 产品id  title 标题 subtitle 副标题 integral 价格 afterService 服务 descript 详情  " +
                             "  images [imgSrc] 主轮播图 " +
                             "colors [productColorId 产品颜色id name 颜色名称] specs [productSpecId 产品规格id name 规格名称] " +
                             "skus [productSpecId 产品规格id productColorId 产品颜色id  sukId sku的id stocks 库存 integral 价格 ] " +
                             "recs 推荐[productId 产品id  title 标题  integral 价格   imgSrc 主 图]" +
                                "comment评论 {{  userId 评论用户 uName 评论用户名称 headImg 评论用户头像 content 内容 replyUserId 回复id rName回复用户名称 rheadImg回复用户头像 createDate 创建时间  images[imgSrc 评论图片] } } }"),
                     @ResponseHeader(name="msg",description = "失败原因") })

     })
     public void getLuckyBurstById(){
         String productId=getPara("productId");

         ReqResponse<Record> r=new ReqResponse();
         Record record=productService.getLuckyBurstById(productId);

         int currentHour=0,beginDate=0,endDate=0 ;
         String currentTime="";
         if(null!=record) {
             currentHour = record.getInt("currentHour");
             beginDate = record.getInt("beginDate");
             endDate =  record.getInt("endDate");
             currentTime=record.getStr("currentTime");
         }
         record.set("currentTime", currentTime);
         record.set("beginDate", beginDate);
         record.set("endDate", endDate);
         record.set("currentHour", currentHour);
         record.set("sortDate", currentHour-beginDate);
         if(currentHour>=beginDate&&currentHour<endDate){
             record.set("sortDate",0);
         }
         else{
             if(currentHour-beginDate>0) {
                 record.set("sortDate", currentHour-beginDate-24);
             }
         }
         r.setData(record);
         renderJson(r);
     }


     @ApiOperation(url = "/v1/shop/getSeckillALLList", tag = "shop", httpMethod = "post",description = "乐购-秒杀列表")
     @Params({

             @Param(name = "pageNumber", description = "页码", required = true, dataType = "string")
     })
     @ApiResponses({
             @ApiResponse(code=200,message="成功",responseHeaders={
                     @ResponseHeader(name="code",description = " 0成功 1失败"),
                     @ResponseHeader(name="data",description = "{     beginDate 开始时间 endDate 结束时间 sortDate 离结束多久  currentTime 当前时间    " +
                             "productId 产品id imgSrc图片 integral价格   subtitle 副标题  title 标题 ，activityStocks 活动库存 activityPrice活动价格 lastStocks 剩余库存 " +
                             "[users {  uid 用户id,headImg头像 ,uName 用户名称} ]   }"),
                     @ResponseHeader(name="msg",description = "失败原因") })

     })
     public void getSeckillALLList(){
         int pageNumber=getParaToInt("pageNumber");

         ReqResponse<Page<Record>> r=new ReqResponse();
         Page<Record>  records= productService.getSeckillALLList(pageNumber);


         r.setData(records);
         renderJson(r);
     }
     @ApiOperation(url = "/v1/shop/getSeckillById", tag = "shop", httpMethod = "post",description = "乐购-秒杀商品详情")
     @Params({

             @Param(name = "productId", description = "产品id", required = true, dataType = "string")
     })
     @ApiResponses({
             @ApiResponse(code=200,message="成功",responseHeaders={
                     @ResponseHeader(name="code",description = " 0成功 1失败"),
                     @ResponseHeader(name="data",description = "{  beginDate 开始时间 endDate 结束时间 sortDate 离结束多久  currentTime 当前时间" +
                             "activityStocks 活动库存 activityPrice活动价格   lastStocks 剩余库存 [users {  uid 用户id,headImg头像 ,uName 用户名称} ] ] }" +
                             " productId 产品id  title 标题 subtitle 副标题 integral 价格 afterService 服务 descript 详情  " +
                             "  images [imgSrc] 主轮播图 " +
                             "colors [productColorId 产品颜色id name 颜色名称] specs [productSpecId 产品规格id name 规格名称] " +
                             "skus [productSpecId 产品规格id productColorId 产品颜色id  sukId sku的id stocks 库存 integral 价格 ] " +
                             "recs 推荐[productId 产品id  title 标题  integral 价格   imgSrc 主 图]" +
                             "comment评论 {{  userId 评论用户 uName 评论用户名称 headImg 评论用户头像 content 内容 replyUserId 回复id rName回复用户名称 rheadImg回复用户头像 createDate 创建时间  images[imgSrc 评论图片] } } }"),
                     @ResponseHeader(name="msg",description = "失败原因") })

     })
     public void getSeckillById(){
         String productId=getPara("productId");

         ReqResponse<Record> r=new ReqResponse();
         Record record=productService.getSeckillById(productId);

         int currentHour=0,beginDate=0,endDate=0 ;
         String currentTime="";
         if(null!=record) {
             currentHour = record.getInt("currentHour");
             beginDate = record.getInt("beginDate");
             endDate =  record.getInt("endDate");
             currentTime=record.getStr("currentTime");
         }
         record.set("currentTime", currentTime);
         record.set("beginDate", beginDate);
         record.set("endDate", endDate);
         record.set("currentHour", currentHour);
         record.set("sortDate", currentHour-beginDate);
         if(currentHour>=beginDate&&currentHour<endDate){
             record.set("sortDate",0);
         }
         else{
             if(currentHour-beginDate>0) {
                 record.set("sortDate", currentHour-beginDate-24);
             }
         }
         r.setData(record);
         renderJson(r);
     }
 */
    @ApiOperation(url = "/v1/shop/getProductById", tag = "shop", httpMethod = "post", description = "乐购-商品详情")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "productId", description = "产品id", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ userId  用户id productId 产品id  title 标题 subtitle 副标题 integral 价格 orders 月销量数 lb 乐币价格 afterService 服务 descript 详情    images [imgSrc] 主轮播图 colors [productColorId 产品颜色id name 颜色名称] specs [productSpecId 产品规格id name 规格名称] skus [productSpecId 产品规格id productColorId 产品颜色id  sukId sku的id stocks 库存 integral 价格 ] " +
                            "recs 推荐[productId 产品id  title 标题  integral 价格   imgSrc 主 图]" +
                            "coupons 优惠券[couponId 优惠券id  title 名称]" +
                            "shop店铺{imgSrc店铺logo name店铺名称 shopId 店铺id num商品数量 orders销量}" +
                            "comment评论 {{  userId 评论用户 uName 评论用户名称 headImg 评论用户头像 content 内容 replyUserId 回复id rName回复用户名称 rheadImg回复用户头像 createDate 创建时间  images[imgSrc 评论图片] } } }" +
                     "freRecs{ freightId 运费模板ID isSystem 是否系统模板 0-否 1-是  isExcept 是否除之外 0-否 1-是  provinceId 省id proviceName 省名称 piece 件 money金额  addPiece 增加件 addMoney 增加金额 remarks 备注 subFreRecsList[{ freightId 运费模板ID provinceId 省id subProviceName 省名称 piece 件 money金额  addPiece 增加件 addMoney 增加金额 remarks 备注  }] 子运费模板  }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    @Clear
    public void getProductById() {
        String productId = getPara("productId");

        ReqResponse<Record> r = new ReqResponse();
        Record record = productService.getProductById(productId);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/getCouponsByProductId", tag = "shop", httpMethod = "post", description = "乐购-商品-优惠券列表")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "productId", description = "产品id", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ recs 推荐[couponId 优惠券id discount折扣 title 名称   imgSrc 图 integral 乐币 beginTime 开始时间 endTime 结束时间 pintegral 产品价格]" +
                            "coupons 优惠券[couponId 优惠券id  title 名称 isHas 1已经购买0没有discount 折扣 imgSrc 图 integral 乐币 beginTime 开始时间 endTime 结束时间 pintegral 产品价格] "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    @Clear
    public void getCouponsByProductId() {
        String productId = getPara("productId");
        String token = getPara("loginUid");
        String loginUid = "";
        if (StrKit.notBlank(token)) {
            Map<String, Claim> map = JwtUtil.unsign(token);
            if (map != null) {
                loginUid = map.get("user_id").asString();
            }
        }
        ReqResponse<Record> r = new ReqResponse();
        Record record = productService.getCouponsByProductId(loginUid, productId);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/getMyCouponsByProductId", tag = "shop", httpMethod = "post", description = "乐购-我的-商品-优惠券列表")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "productId", description = "产品id", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{  " +
                            " couponId 优惠券id  title 名称  discount 折扣 imgSrc 图 integral 乐币 beginTime 开始时间 endTime 结束时间 pintegral 产品价格 "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getMyCouponsByProductId() {
        String productId = getPara("productId");
        String loginUid = getAttr("loginUid");

        ReqResponse<List<Record>> r = new ReqResponse();
        List<Record> record = productService.getMyCouponsByProductId(loginUid, productId);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/getCouponByCouponId", tag = "shop", httpMethod = "post", description = "乐购-优惠券详情")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "couponId", description = "优惠券id", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{   " +
                            " couponId 优惠券id  title 名称  imgSrc 图 integral 乐币 discount  折扣 beginTime 开始时间 endTime 结束时间 remarks说明 imgs 轮播图[imgSrc]  ] "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    @Clear
    public void getCouponByCouponId() {
        String couponId = getPara("couponId");
        ReqResponse<Record> r = new ReqResponse();
        Record record = productService.getCouponByCouponId(couponId);
        if (StrKit.notBlank(record.getStr("coupons"))) {
            r.setCode(1);
            r.setMsg("券未找到");
            renderJson(r);
        } else {
            r.setData(record);
            renderJson(r);
        }

    }

    @ApiOperation(url = "/v1/shop/buyCoupon", tag = "shop", httpMethod = "post", description = "乐购-购买优惠券")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "couponId", description = "优惠券id", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void buyCoupon() {
        String loginUid = getAttr("loginUid");
        String couponId = getPara("couponId");
        ReqResponse<Record> r = new ReqResponse();
        try {
            enhance(OrderService.class).buyCoupon(couponId, loginUid);
        } catch (BusinessException e) {
            r.setCode(1);
            r.setMsg(e.getMessage());
        }
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/getMediaProductById", tag = "shop", httpMethod = "post", description = "乐购-个人商品详情")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "provinceId", description = "省份id", required = false, dataType = "string"),
            @Param(name = "productId", description = "产品id", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ productId 产品id  title 标题 subtitle 副标题 integral 价格   descript 详情" +
                            "    images [imgSrc] 主轮播图 freightId 运费id freight 运费 mediaUserId 自媒体商家id" +
                            "user商家信息[ headImg 头像 name 名称  ]" +
                            " skus [model 规格  sukId sku的id num 库存 price 价格 ]  }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    @Clear
    public void getMediaProductById() {
        String productId = getPara("productId");
        String provinceId = getPara("provinceId");

        ReqResponse<Record> r = new ReqResponse();
        Record record = productService.getMediaProductById(productId, provinceId);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/getProductCommentById", tag = "shop", httpMethod = "post", description = "乐购-商品评价")
    @Params({

            @Param(name = "productId", description = "产品id", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ list[{ replyContent 回复内容 orderDate 订单日期 specName 规格名称 colorName颜色名称 star 评分等级 userId 评论用户 uName 评论用户名称 headImg 评论用户头像 content 内容 replyUserId 回复id rName回复用户名称 rheadImg回复用户头像 createDate 创建时间  images[imgSrc 评论图片] }    }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getProductCommentById() {
        String productId = getPara("productId");
        int pageNumber = getParaToInt("pageNumber");
        ReqResponse<Page<Record>> r = new ReqResponse();
        Page<Record> record = productService.getProductCommentById(productId, pageNumber);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/getProductSkuBySku", tag = "shop", httpMethod = "post", description = "乐购-商品Sku信息")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "skuId", description = "skuid", required = true, dataType = "string")

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ productId 产品id integral 价格 skuId  stocks 库存 discount 折扣 images[{imgSrc 图片   第一张为主图  }]  }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    @Clear
    public void getProductSkuBySku() {
        String skuId = getPara("skuId");

        ReqResponse<Record> r = new ReqResponse();
        Record record = productService.getProductSkuBySku(skuId);
        List<Record> records = productService.getProductSkuImagesBySku(skuId);

        record.set("images", records);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/getUserDeliveryAddressList", tag = "shop", httpMethod = "post", description = "乐购-用户收货地址")
    @Params({

            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ addressId 地址id uid 用户id consignee收货人  phone 电话 address 地址 isDefault 是否默认 1是 0否 " +
                            "provinceId 省份id provinceName 省份名称 cityId城市id  cityName 城市名称 areaId 区id areaName 区名称 }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getUserDeliveryAddressList() {
        String loginUid = getAttr("loginUid");
        UserService userService = new UserService();
        ReqResponse<List<Record>> r = new ReqResponse();
        List<Record> records = userService.getUserDeliveryAddressList(loginUid);

        r.setData(records);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/getShopById", tag = "shop", httpMethod = "post", description = "乐购-店铺页")
    @Params({
            @Param(name = "shopId", description = "店铺id", required = true, dataType = "string"),
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{carousels 轮播图[imgSrc ]shopId 店铺id  name 名称 imgSrc logo orderCount 订单数 collectCount收藏数 isCollect 1收藏0没有}"),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    @Clear
    public void getShopById() {
        String token = getPara("loginUid");
        String loginUid = "";
        if (StrKit.notBlank(token)) {
            Map<String, Claim> map = JwtUtil.unsign(token);
            loginUid = map.get("user_id").asString();
        }
        String shopId = getPara("shopId");
        ReqResponse<Record> r = new ReqResponse();
        Record records = shopService.getShopById(shopId, loginUid);
        r.setData(records);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/collectShopById", tag = "shop", httpMethod = "post", description = "乐购-收藏店铺 ")
    @Params({
            @Param(name = "shopId", description = "店铺id", required = true, dataType = "string"),
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "state", description = "1收藏0取消收藏", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{carousels 轮播图[imgSrc ]shopId 店铺id  name 名称 imgSrc logo orderCount 订单数 collectCount收藏数 isCollect 1收藏0没有}"),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void collectShopById() {
        String loginUid = getAttr("loginUid");
        String shopId = getPara("shopId");
        String state = getPara("state");
        ReqResponse<Record> r = new ReqResponse();
        shopService.collectShopById(shopId, loginUid, state);

        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/getShopRemProduct", tag = "shop", httpMethod = "post", description = "乐购-店铺-推荐商品")
    @Params({
            @Param(name = "shopId", description = "店铺id", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "分页", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{   title 名称  imgSrc 图 integral 价格 couponCount 优惠券数量 }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void getShopRemProduct() {
        String shopId = getPara("shopId");
        int pageNumber = getParaToInt("pageNumber");
        ReqResponse<Page<Record>> r = new ReqResponse();
        Page<Record> records = shopService.getShopRemProduct(shopId, pageNumber);
        r.setData(records);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/getShopProduct", tag = "shop", httpMethod = "post", description = "乐购-店铺-商品页")
    @Params({
            @Param(name = "shopId", description = "店铺id", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "分页", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{   title 名称  imgSrc 图 integral 价格 couponCount 优惠券数量 }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void getShopProduct() {
        String shopId = getPara("shopId");
        int pageNumber = getParaToInt("pageNumber");
        ReqResponse<Page<Record>> r = new ReqResponse();
        Page<Record> records = shopService.getShopProduct(shopId, pageNumber);
        r.setData(records);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/getNewUserVip", tag = "shop", httpMethod = "post", description = "获取新人专享类型 ")
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{  carousels 轮播图[imgSrc图片路径 imgRank 序号   model 1商品2专题  productId 产品id specialId 专题id]  types[ title 标题 subtitle 副标题 typeId 热度类型id   currentTime 当前时间 beginDate 开始时间 endDate 结束时间 sortDate 离现在时间]}"),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void getNewUserVip() {
        ReqResponse<Record> r = new ReqResponse();
        Record record = shopService.getNewUserVip();
        List<Record> carousels = categoryService.getCarouselList(2);
        record.set("carousels", carousels);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/getNewUserVipList", tag = "shop", httpMethod = "post", description = "获取新人专享类型-列表")
    @Params({
            @Param(name = "typeId", description = "热度类型id ", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "totalRow 总行数  pageNumber第几页 firstPage 是否第一页 lastPage 是否最后一页 totalPage 总页数 pageSize每页条数  list[{ discount 折扣 imgSrc图片  title 标题 pintegral 产品价格 vipCouponId 优惠券id lastStocks剩余库存 activityStocks 总库存 integral 乐币}]"),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void getNewUserVipList() {
        String id = getPara("typeId");
        int pageNumber = getParaToInt("pageNumber");
        ReqResponse<Page<Record>> r = new ReqResponse();
        Page<Record> record = shopService.getNewUserVipList(id, pageNumber);
        r.setData(record);
        renderJson(r);
    }


    @ApiOperation(url = "/v1/shop/getShopProductByOrder", tag = "shop", httpMethod = "post", description = "乐购-店铺-热销页")
    @Params({
            @Param(name = "shopId", description = "店铺id", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "分页", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{   title 名称  imgSrc 图 integral 价格 couponCount 优惠券数量 }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void getShopProductByOrder() {
        String shopId = getPara("shopId");
        int pageNumber = getParaToInt("pageNumber");
        ReqResponse<Page<Record>> r = new ReqResponse();
        Page<Record> records = shopService.getShopProductByOrder(shopId, pageNumber);
        r.setData(records);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/getShopProductByCreate", tag = "shop", httpMethod = "post", description = "乐购-店铺-上新页")
    @Params({
            @Param(name = "shopId", description = "店铺id", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "分页", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{  day1 天 products[ title 名称  imgSrc 图 integral 价格 couponCount 优惠券数量] }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void getShopProductByCreate() {
        String shopId = getPara("shopId");
        int pageNumber = getParaToInt("pageNumber");
        ReqResponse<Page<Record>> r = new ReqResponse();
        Page<Record> records = shopService.getShopProductByCreate(shopId, pageNumber);
        r.setData(records);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/getShopInfo", tag = "shop", httpMethod = "post", description = "乐购-店铺信息")
    @Params({
            @Param(name = "shopId", description = "店铺id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{   products 商品数 news 上新数 hots 热销数 orders销量数 remarks 简介 createDate 开店时间 }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void getShopInfo() {
        String shopId = getPara("shopId");

        ReqResponse<Record> r = new ReqResponse();
        Record records = shopService.getShopInfo(shopId);
        r.setData(records);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/addUserDeliveryAddress", tag = "shop", httpMethod = "post", description = "乐购-增加或者修改用户收货地址")
    @Params({
            @Param(name = "addressId", description = "地址id", required = false, dataType = "string"),
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "consignee", description = "收货", required = true, dataType = "string"),
            @Param(name = "phone", description = "电话", required = true, dataType = "string"),
            @Param(name = "address", description = "地址", required = true, dataType = "string"),
            @Param(name = "isDefault", description = "是否默认 1是 0否", required = true, dataType = "string"),
            @Param(name = "provinceId", description = "省份id", required = true, dataType = "string"),
            @Param(name = "cityId", description = "城市id", required = true, dataType = "string"),
            @Param(name = "areaId", description = "区id", required = true, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void addUserDeliveryAddress() {

        ReqResponse<String> r = new ReqResponse();

        String addressId = getPara("addressId");
        String loginUid = getAttr("loginUid");
        String consignee = getPara("consignee");
        String phone = getPara("phone");
        String address = getPara("address");
        String isDefault = getPara("isDefault");
        String provinceId = getPara("provinceId");
        String cityId = getPara("cityId");
        String areaId = getPara("areaId");

        boolean flag = false;


        if (StrKit.isBlank(consignee)) {
            flag = true;
            r.setCode(1);
            r.setMsg("收货人为空");
            renderJson(r);
        }


        if (StrKit.isBlank(phone)) {
            flag = true;
            r.setCode(1);
            r.setMsg("收货人电话为空");
            renderJson(r);
        }

        if (StrKit.isBlank(address)) {
            flag = true;
            r.setCode(1);
            r.setMsg("收货人地址为空");
            renderJson(r);
        }

        if (StrKit.isBlank(provinceId)) {
            flag = true;
            r.setCode(1);
            r.setMsg("省ID为空");
            renderJson(r);
        }

        if (StrKit.isBlank(cityId)) {
            flag = true;
            r.setCode(1);
            r.setMsg("城市ID为空");
            renderJson(r);
        }

        if (!flag) {
            UserService userService = enhance(UserService.class);
            try {
                userService.addUserDeliveryAddress(addressId, loginUid, consignee, phone, address, isDefault, provinceId, cityId, areaId);
            } catch (Exception e) {
                e.printStackTrace();
                r.setCode(1);
                r.setData("保存失败");
            }
            r.setData("");
            renderJson(r);
        }
    }


    @ApiOperation(url = "/v1/shop/deleteUserDeliveryAddress", tag = "shop", httpMethod = "post", description = "乐购-删除用户收货地址")
    @Params({

            @Param(name = "addressId", description = "地址id", required = false, dataType = "string"),
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),


    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void deleteUserDeliveryAddress() {
        String addressId = getPara("addressId");
        String loginUid = getAttr("loginUid");

        UserService userService = enhance(UserService.class);
        ReqResponse<String> r = new ReqResponse();
        try {
            userService.deleteUserDeliveryAddress(addressId, loginUid);
        } catch (Exception e) {
            e.printStackTrace();
            r.setCode(1);
            r.setData("保存失败");
        }

        r.setData("");
        renderJson(r);
    }
   /* @ApiOperation(url = "/v1/shop/getUserUnpaidList", tag = "shop", httpMethod = "post",description = "乐购-用户未支付订单")
    @Params({

            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code=200,message="成功",responseHeaders={
                    @ResponseHeader(name="code",description = " 0成功 1失败"),
                    @ResponseHeader(name="data",description = "{ orderId 订单id orderNumber 订单号码 imgSrc 图片 title 标题 productId 产品id skuId  skuid number 数量 " +
                            "activityType 活动类型1爆款2秒杀 3折扣   price 价格   colorName 颜色  specName 规格  limitTime截止时间 }"),
                    @ResponseHeader(name="msg",description = "失败原因") })

    })
    public void getUserUnpaidList(){
        String loginUid=getAttr("loginUid");
        OrderService orderService=new OrderService();
        ReqResponse<List<Record>> r=new ReqResponse();
        List<Record> records=orderService.getUserUnpaidList(loginUid);

        r.setData(records);
        renderJson(r);
    }*/



/*


    @ApiOperation(url = "/v1/shop/getUserPaidList", tag = "shop", httpMethod = "post",description = "乐购-用户已支付订单")
    @Params({

            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code=200,message="成功",responseHeaders={
                    @ResponseHeader(name="code",description = " 0成功 1失败"),
                    @ResponseHeader(name="data",description = "{ orderId 订单id orderNumber 订单号码 imgSrc 图片 title 标题 productId 产品id skuId  skuid number 数量 " +
                            "   colorName 颜色  specName 规格  }"),
                    @ResponseHeader(name="msg",description = "失败原因") })

    })
    public void getUserPaidList(){
        String loginUid=getAttr("loginUid");
        OrderService orderService=new OrderService();
        ReqResponse<List<Record>> r=new ReqResponse();
        List<Record> records=orderService.getUserPaidList(loginUid);

        r.setData(records);
        renderJson(r);
    }
*/
/*

    @ApiOperation(url = "/v1/shop/getUserUnreceivedList", tag = "shop", httpMethod = "post",description = "乐购-用户未收货订单")
    @Params({

            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code=200,message="成功",responseHeaders={
                    @ResponseHeader(name="code",description = " 0成功 1失败"),
                    @ResponseHeader(name="data",description = "{ orderId 订单id orderNumber 订单号码 imgSrc 图片 title 标题 productId 产品id skuId  skuid number 数量 " +
                            "   colorName 颜色  specName 规格  }"),
                    @ResponseHeader(name="msg",description = "失败原因") })

    })
    public void getUserUnreceivedList(){
        String loginUid=getAttr("loginUid");
        OrderService orderService=new OrderService();
        ReqResponse<List<Record>> r=new ReqResponse();
        List<Record> records=orderService.getUserUnreceivedList(loginUid);

        r.setData(records);
        renderJson(r);
    }
*/

/*
    @ApiOperation(url = "/v1/shop/getUserReceivedList", tag = "shop", httpMethod = "post",description = "乐购-用户收货订单")
    @Params({

            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code=200,message="成功",responseHeaders={
                    @ResponseHeader(name="code",description = " 0成功 1失败"),
                    @ResponseHeader(name="data",description = "{ orderId 订单id orderNumber 订单号码 imgSrc 图片 title 标题 productId 产品id skuId  skuid number 数量 " +
                            "   colorName 颜色  specName 规格  }"),
                    @ResponseHeader(name="msg",description = "失败原因") })

    })
    public void getUserReceivedList(){
        String loginUid=getAttr("loginUid");
        OrderService orderService=new OrderService();
        ReqResponse<List<Record>> r=new ReqResponse();
        List<Record> records=orderService.getUserReceivedList(loginUid);

        r.setData(records);
        renderJson(r);
    }*/
/*
    @ApiOperation(url = "/v1/shop/getPayByOrderIds", tag = "shop", httpMethod = "post",description = "乐购-用户订单支付信息")
    @Params({

            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "orderId", description = "订单数组orderId=1&orderId=2", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code=200,message="成功",responseHeaders={
                    @ResponseHeader(name="code",description = " 0成功 1失败"),
                    @ResponseHeader(name="data",description = "{ integral 用户乐币 orderIntegral 订单乐币" +
                            "products[orderId 订单id orderNumber 订单号码 imgSrc 图片 title 标题 productId 产品id skuId  skuid number 数量 " +
                            "   colorName 颜色  specName 规格 ] }"),
                    @ResponseHeader(name="msg",description = "失败原因") })

    })
    public void getPayByOrderIds(){
        String loginUid=getAttr("loginUid");
        String orderIds[]=getParaValues("orderId");
        OrderService orderService=new OrderService();
        ReqResponse<Record> r=new ReqResponse();
         Record  records=orderService.getPayByOrderIds(loginUid,orderIds);

        r.setData(records);
        renderJson(r);
    }*/

    /*@ApiOperation(url = "/v1/shop/payByOrderIds", tag = "shop", httpMethod = "post",description = "乐购-用户订单支付")
    @Params({

            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "orderId", description = "订单数组orderId=1&orderId=2", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code=200,message="成功",responseHeaders={
                    @ResponseHeader(name="code",description = " 0成功 1失败"),
                    @ResponseHeader(name="data",description = " "),
                    @ResponseHeader(name="msg",description = "失败原因") })

    })
    public void payByOrderIds(){
        OrderService orderService=enhance(OrderService.class);
        String loginUid=getAttr("loginUid");
        String orderIds[]=getParaValues("orderId");
        ReqResponse<Record> r=new ReqResponse();
         boolean f= orderService.payByOrderIds(loginUid,orderIds);
       if(!f){
           r.setCode(1);
           r.setMsg("支付失败");
       }

        renderJson(r);
    }*/


    @ApiOperation(url = "/v1/shop/getNewUserVipCouponByCouponId", tag = "shop", httpMethod = "post", description = "乐购-新人专享优惠券详情")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "vipCouponId", description = "优惠券id", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{   " +
                            " vipCouponId 优惠券id  title 名称  imgSrc 图 integral 乐币 discount  折扣 beginTime 开始时间 endTime 结束时间 remarks说明 imgs 轮播图[imgSrc]  ] "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    @Clear
    public void getNewUserVipCouponByCouponId() {
        String couponId = getPara("vipCouponId");
        ReqResponse<Record> r = new ReqResponse();
        Record record = productService.getNewUserVipCouponByCouponId(couponId);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/buyNewUserVipCoupon", tag = "shop", httpMethod = "post", description = "乐购-购买新人专享优惠券")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "vipCouponId", description = "优惠券id", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void buyNewUserVipCoupon() {
        String loginUid = getAttr("loginUid");
        String couponId = getPara("vipCouponId");
        ReqResponse<Record> r = new ReqResponse();
        try {
            enhance(OrderService.class).buyNewUserVipCoupon(couponId, loginUid);
        } catch (BusinessException e) {
            r.setCode(1);
            r.setMsg(e.getMessage());
        }
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/getCollageList", tag = "shop", httpMethod = "post", description = "获取拼团-列表")
    @Params({
            @Param(name = "sortId", description = "排序字段 综合create_date  价格 integral ", required = false, dataType = "string"),
            @Param(name = "sortValue", description = "排序值 asc 升 desc 降 ", required = false, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "totalRow 总行数  pageNumber第几页 firstPage 是否第一页 lastPage " +
                            "是否最后一页 totalPage 总页数 pageSize每页条数  " +
                            "list[{ discount 折扣 imgSrc图片  title 标题 pintegral 产品价格 collageCouponId 优惠券id   integral 乐币 orders已拼件数 num 拼团人数}]"),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })

    public void getCollageList() {
        String sortId = getPara("sortId");
        String sortValue = getPara("sortValue");
        int pageNumber = getParaToInt("pageNumber");
        ReqResponse<Page<Record>> r = new ReqResponse();
        if (StrKit.isBlank(sortId)) {
            sortId = "create_date";
        }
        if (StrKit.isBlank(sortValue)) {
            sortValue = "desc";
        }
        Page<Record> record = shopService.getCollageList(sortId, sortValue, pageNumber);
        r.setData(record);
        renderJson(r);
    }


    @ApiOperation(url = "/v1/shop/getCollageByCouponId", tag = "shop", httpMethod = "post", description = "获取拼团-详情")
    @Params({

            @Param(name = "collageCouponId", description = " 拼团优惠券id ", required = false, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{   " +
                            " collageCouponId 优惠券id  title 名称  imgSrc 图 ctitle 优惠券名称 integral 乐币 discount  折扣 beginTime 开始时间 endTime 结束时间 remarks说明 imgs 轮播图[imgSrc]  ] "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void getCollageByCouponId() {
        String couponId = getPara("collageCouponId");
        ReqResponse<Record> r = new ReqResponse();
        Record record = productService.getCollageByCouponId(couponId);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/getCollageByOrderNumber", tag = "shop", httpMethod = "post", description = "获取拼团-订单详情")
    @Params({

            @Param(name = "orderNumber", description = "拼团订单id", required = false, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{   " +
                            "productId 商品id lastNum 剩余人数 num 开团人数 orderNumber 订单号 currentTime 当前时间 title 名称  imgSrc 图   integral 乐币 discount  折扣 beginTime 开始时间 endTime 结束时间  createDate 订单日期  endDate 订单结束时间] "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void getCollageByOrderNumber() {
        String orderNumber = getPara("orderNumber");
        ReqResponse<Record> r = new ReqResponse();
        Record record = productService.getCollageByOrderNumber(orderNumber);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/buyCollageByCouponId", tag = "shop", httpMethod = "post", description = "乐购-购买拼团优惠券")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "collageCouponId", description = "优惠券id", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " collageOrderId 订单id"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void buyCollageByCouponId() {
        String loginUid = getAttr("loginUid");
        String couponId = getPara("collageCouponId");
        ReqResponse<Record> r = new ReqResponse();
        try {
            r.setData(enhance(OrderService.class).buyCollageByCouponId(couponId, loginUid));
        } catch (BusinessException e) {
            r.setCode(1);
            r.setMsg(e.getMessage());
        }
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/buyCollageByOrderId", tag = "shop", httpMethod = "post", description = "乐购-拼团")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "orderNumber", description = "拼团订单id", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void buyCollageByOrderId() {
        String loginUid = getAttr("loginUid");
        String orderNumber = getPara("orderNumber");
        ReqResponse<Record> r = new ReqResponse();
        try {
            r.setData(enhance(OrderService.class).buyCollageByOrderId(orderNumber, loginUid));
        } catch (BusinessException e) {
            r.setCode(1);
            r.setMsg(e.getMessage());
        }
        renderJson(r);
    }


    @ApiOperation(url = "/v1/shop/getLuckyBurst", tag = "shop", httpMethod = "post", description = "获取爆款活动类型 ")
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{  carousels 轮播图[imgSrc图片路径 imgRank 序号   model 1商品2专题  productId 产品id specialId 专题id]  types[ title 标题 subtitle 副标题 typeId 热度类型id   currentTime 当前时间 beginDate 开始时间 endDate 结束时间 sortDate 离现在时间]}"),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void getLuckyBurst() {
        ReqResponse<Record> r = new ReqResponse();
        Record record = shopService.getLuckyBurst();
        List<Record> carousels = categoryService.getCarouselList(3);
        record.set("carousels", carousels);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/getLuckyBurstList", tag = "shop", httpMethod = "post", description = "获取爆款活动-列表")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = false, dataType = "string"),
            @Param(name = "typeId", description = "热度类型id ", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "  " +
                            "{ state -1 默认 1成功0失败 discount 折扣 imgSrc图片  title 标题 pintegral userCount 用户总数 currentTime 当前时间 beginDate 开始时间 endDate 结束时间 sortDate 离现在时间" +
                            "产品价格 burstCouponId 优惠券id lastStocks剩余库存 " +
                            "integral 乐币 u{orderNumber 订单编号，num 能量值 name 用户名称ranking 排名 headimg 头像 }" +
                            "list [ num 能量值 name 用户名称ranking 排名 headimg 头像 ]} "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    @Clear
    public void getLuckyBurstList() {
        String id = getPara("typeId");
        String token = getPara("loginUid");
        String loginUid = "";
        if (StrKit.notBlank(token)) {
            Map<String, Claim> map = JwtUtil.unsign(token);
            loginUid = map.get("user_id").asString();
        }

        ReqResponse<Record> r = new ReqResponse();
        r.setData(shopService.getLuckyBurstList(id, loginUid));
        renderJson(r);
    }


    @ApiOperation(url = "/v1/shop/getLuckyBurstListEx", tag = "shop", httpMethod = "post", description = "获取爆款活动-新列表")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "typeId", description = "热度类型id ", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "  " +
                            "list [{ state -1 默认 1成功0失败 discount 折扣 imgSrc图片  title 标题 pintegral userCount 用户总数 currentTime 当前时间 beginDate 开始时间 endDate 结束时间 sortDate 0-活动中 -1-活动未开始 1-活动已结束" +
                            "产品价格 burstCouponId 优惠券id lastStocks剩余库存 " +
                            "integral 乐币 userBuyState 用户是否参与此爆款券 }]"),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    @Clear
    public void getLuckyBurstListEx() {
        String id = getPara("typeId");
        String token = getPara("loginUid");
        String loginUid = "";
        if (StrKit.notBlank(token)) {
            Map<String, Claim> map = JwtUtil.unsign(token);
            loginUid = map.get("user_id").asString();
        }
        ReqResponse<List<Record>> r = new ReqResponse();
        r.setData(shopService.getLuckyBurstListEx(id, loginUid));
        renderJson(r);
    }


    @ApiOperation(url = "/v1/shop/buyLuckyBurst", tag = "shop", httpMethod = "post", description = "乐购-购买爆款优惠券")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "burstCouponId", description = "优惠券id", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "orderNumber 订单号 "),
                    @ResponseHeader(name = "msg", description = "失败原因(乐币不够,此券已卖光) ")})

    })
    public void buyLuckyBurst() {
        String loginUid = getAttr("loginUid");
        String burstCouponId = getPara("burstCouponId");
        ReqResponse<Record> r = new ReqResponse();
        try {
            r.setData(enhance(OrderService.class).buyLuckyBurst(burstCouponId, loginUid));
        } catch (BusinessException e) {
            r.setCode(1);
            r.setMsg(e.getMessage());
        }
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/luckyBurstDetail", tag = "shop", httpMethod = "post", description = "乐购-爆款优惠-详情")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "orderNumber", description = "爆款订单id", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ discount 折扣 imgSrc图片 currentTime 当前时间 beginDate 开始时间 endDate 结束时间 sortDate 离现在时间  title 标题 pintegral userCount 用户总数" +
                            "产品价格 burstCouponId 优惠券id lastStocks剩余库存 totalNum 总能量值" +
                            "integral 乐币 u{orderId 订单id，num 能量值 name 用户名称ranking 排名 headimg 头像 }" +
                            "list [ num 能量值 name 用户名称ranking 排名 headimg 头像 ] state -1 默认 1成功0失败 " +
                            "advs [ title 标题 imgSrc 视频文件 luckyBurstAdvId 广告id coverImgSrc 封面 ] "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    @Clear
    public void luckyBurstDetail() {
        String token = getPara("loginUid");
        String loginUid = "";
        if (StrKit.notBlank(token)) {
            Map<String, Claim> map = JwtUtil.unsign(token);
            if (map != null) {
                loginUid = map.get("user_id").asString();
            }
        }
        String orderNumber = getPara("orderNumber");
        ReqResponse<Record> r = new ReqResponse();
        try {
            r.setData(enhance(OrderService.class).luckyBurstDetail(orderNumber, loginUid));
        } catch (BusinessException e) {
            r.setCode(1);
            r.setMsg(e.getMessage());
        }
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/luckyBurstDetailEx", tag = "shop", httpMethod = "post", description = "乐购-爆款优惠-详情")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "orderNumber", description = "爆款订单id", required = true, dataType = "string"),
            @Param(name = "typeId", description = "类型Id", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ discount 折扣 imgSrc图片 currentTime 当前时间 beginDate 开始时间 endDate 结束时间 sortDate 离现在时间  title 标题 pintegral userCount 用户总数" +
                            "产品价格 burstCouponId 优惠券id lastStocks剩余库存 totalNum 总能量值" +
                            "integral 乐币 u{orderId 订单id，num 能量值 name 用户名称ranking 排名 headimg 头像 }" +
                            "list [ num 能量值 name 用户名称ranking 排名 headimg 头像 ] state -1 默认 1成功0失败 " +
                            "advs [ title 标题 imgSrc 视频文件 luckyBurstAdvId 广告id coverImgSrc 封面 ] "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    @Clear
    public void luckyBurstDetailEx() {
        String token = getPara("loginUid");
        String typeId = getPara("typeId");
        String loginUid = "";
        if (StrKit.notBlank(token)) {
            Map<String, Claim> map = JwtUtil.unsign(token);
            if (map != null) {
                loginUid = map.get("user_id").asString();
            }
        }
        String orderNumber = getPara("orderNumber");
        ReqResponse<Record> r = new ReqResponse();
        try {
            r.setData(enhance(OrderService.class).luckyBurstDetailEx(orderNumber, loginUid,typeId));
        } catch (BusinessException e) {
            r.setCode(1);
            r.setMsg(e.getMessage());
        }
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/getLuckyBurstByAdv", tag = "shop", httpMethod = "post", description = "乐购-爆款优惠-看视频获取能量")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "luckyBurstAdvId", description = "广告id", required = true, dataType = "string"),
            @Param(name = "orderNumber", description = "爆款订单id", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getLuckyBurstByAdv() {
        String loginUid = getAttr("loginUid");
        String orderNumber = getPara("orderNumber");
        String luckyBurstAdvId = getPara("luckyBurstAdvId");
        ReqResponse<Record> r = new ReqResponse();
        try {
            r.setData(enhance(OrderService.class).getLuckyBurstByAdv(orderNumber, loginUid, luckyBurstAdvId));
        } catch (BusinessException e) {
            r.setCode(1);
            r.setMsg(e.getMessage());
        }
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/getLuckyBurstByFriend", tag = "shop", httpMethod = "post", description = "乐购-爆款优惠-好友点赞获取能量")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = false, dataType = "string"),
            @Param(name = "orderNumber", description = "爆款订单id", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getLuckyBurstByFriend() {
        String loginUid = getAttr("loginUid");
        String orderNumber = getPara("orderNumber");
        ReqResponse<Record> r = new ReqResponse();
        try {
            r.setData(enhance(OrderService.class).getLuckyBurstByFriend(orderNumber, loginUid));
        } catch (BusinessException e) {
            r.setCode(1);
            r.setMsg("非好友暂时不能助力");
        }
        renderJson(r);
    }


    @ApiOperation(url = "/v1/shop/getLuckyBurstByFriendEx", tag = "shop", httpMethod = "post", description = "乐购-爆款优惠-好友点赞获取能量")
    @Params({
//            @Param(name = "loginUid", description = "当前用户id", required = false, dataType = "string"),
            @Param(name = "orderNumber", description = "爆款订单id", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getLuckyBurstByFriendEx() {
//        String loginUid = getAttr("loginUid");
        String orderNumber = getPara("orderNumber");
        ReqResponse<Record> r = new ReqResponse();
        try {
            r.setData(enhance(OrderService.class).getLuckyBurstByFriendEx(orderNumber));
        } catch (BusinessException e) {
            r.setCode(1);
            r.setMsg("非好友暂时不能助力");
        }
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/getLuckyBurstFriends", tag = "shop", httpMethod = "post", description = "乐购-爆款优惠-助力好友")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "orderNumber", description = "爆款订单id", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getLuckyBurstFriends() {
        String loginUid = getAttr("loginUid");
        String orderNumber = getPara("orderNumber");
        int pageNumber = getParaToInt("pageNumber");
        ReqResponse<Page<Record>> r = new ReqResponse();
        try {
            r.setData(shopService.getLuckyBurstFriends(orderNumber, pageNumber));
        } catch (BusinessException e) {
            r.setCode(1);
            r.setMsg(e.getMessage());
        }
        renderJson(r);
    }


    @ApiOperation(url = "/v1/shop/shopSearchProductHistory", tag = "shop", httpMethod = "post", description = "商品搜索历史")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ hots 热搜索 [name] historys 搜索历史 [historyId name 名称] }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    @Clear
    public void shopSearchProductHistory() {
        String token = getPara("loginUid");
        String loginUid = "";
        if (StrKit.notBlank(token)) {
            Map<String, Claim> map = JwtUtil.unsign(token);
            loginUid = map.get("user_id").asString();
        }
        ReqResponse<Record> r = new ReqResponse();
        Record record = productService.shopSearchProductHistory(loginUid);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/deleteSearchHistory", tag = "shop", httpMethod = "post", description = "删除搜索历史")
    @Params({
            @Param(name = "historyId", description = "搜索历史id", required = true, dataType = "string"),
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{  }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void deleteSearchHistory() {
        String loginUid = getAttr("loginUid");
        String historyId = getPara("historyId");
        ReqResponse<Record> r = new ReqResponse();
        productService.deleteSearchHistory(loginUid, historyId);

        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/emptySearchHistory", tag = "shop", httpMethod = "post", description = "清空搜索历史")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{  }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void emptySearchHistory() {
        String loginUid = getAttr("loginUid");
        ReqResponse<Record> r = new ReqResponse();
        productService.emptySearchHistory(loginUid);

        renderJson(r);
    }


    @ApiOperation(url = "/v1/shop/searchProduct", tag = "shop", httpMethod = "post", description = "搜索商品 提示框")
    @Params({
            @Param(name = "name", description = "搜索内容", required = true, dataType = "string"),
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ title 名称 }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    @Clear
    public void searchProduct() {
        String token = getPara("loginUid");
        String loginUid = "";
        if (StrKit.notBlank(token)) {
            Map<String, Claim> map = JwtUtil.unsign(token);
            loginUid = map.get("user_id").asString();
        }
        String name = getPara("name");
        ReqResponse<List<Record>> r = new ReqResponse();
        r.setData(productService.searchProduct(loginUid, name));
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/searchProductList", tag = "shop", httpMethod = "post", description = "乐购-搜索-商品列表")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "title", description = "内容", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{    productId 商品id imgSrc 图片 title 标题 subtitle 副标题 integral 价格 couponCount 可用券数量 }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    @Clear
    public void searchProductList() {
        String title = getPara("title");
        int pageNumber = getParaToInt("pageNumber");
        String token = getPara("loginUid");
        String loginUid = "";
        if (StrKit.notBlank(token)) {
            Map<String, Claim> map = JwtUtil.unsign(token);
            loginUid = map.get("user_id").asString();
        }

        ReqResponse<Page<Record>> r = new ReqResponse();
        Page<Record> records = productService.searchProductList(title, pageNumber);
        enhance(ProductService.class).saveSearch(loginUid, title);
        r.setData(records);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/shop/bottomProductList", tag = "shop", httpMethod = "post", description = "乐购-首页-底部商品列表")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{    productId 商品id imgSrc 图片 title 标题 subtitle 副标题 integral 价格 couponCount 可用券数量 }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    @Clear
    public void bottomProductList() {
        String title = getPara("title");
        int pageNumber = getParaToInt("pageNumber");
        String token = getPara("loginUid");
        String loginUid = "";
        if (StrKit.notBlank(token)) {
            Map<String, Claim> map = JwtUtil.unsign(token);
            loginUid = map.get("user_id").asString();
        }

        ReqResponse<Page<Record>> r = new ReqResponse();
        Page<Record> records = productService.bottomProductList(pageNumber);
        System.out.println("***********************************");
        System.out.println(loginUid + "########" + pageNumber);
        System.out.println(records.toString());
        System.out.println(records.getList());


        r.setData(records);
        renderJson(r);
    }
}

